<?php
/**
 * Notes:
 * Created by PhpStorm.
 * Author: TS
 * Date: 2019/10/4
 * Time: 13:21
 */

namespace app\model;


use think\Model;

class Departments extends Model
{
    protected $pk = 'department_id';
    public function getAllDepartment(){
        return self::select();
    }
    public function addDepartment($data){
        $res = self::create($data);
        return $res;
    }
    public function edit($id,$data){
        $res = self::update($data,['department_id'=>$id]);
        return $res;
    }
    public function checkHas($department_id){
        return self::get($department_id);
    }
    public function delDepartment($id){
        return self::get($id)->delete();
    }
    public function check($name){
        return self::get([
            'department_name' => $name
        ]);
    }
    public function getCreateTimeAttr($value){
        return date('Y-m-d H:i',$value);
    }
}